package interview.arraysandstrings;

public class RemoveDuplicateChars {
	public String removeDupChars(String str) {
		char[] array = str.toCharArray();
		int[] alphabet = new int[256];
		int storeIndex = 0;
		for(int i = 0; i < alphabet.length; i++) {
			alphabet[i] = 0;
		}

		for(int i = 0; i < array.length; i++) {
			if(alphabet[array[i]] == 0) {
				array[storeIndex] = array[i];
				storeIndex++;
			}
			alphabet[array[i]]++;
		}

		return new String(array, 0, storeIndex);
	}
}
